package com.youge.controller;

import com.github.pagehelper.PageHelper;
import com.youge.entity.MonthLucky;
import com.youge.service.IMonthLuckyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.ArrayList;
import java.util.List;

/**
 * @author: hcf
 * @qq: 46914685
 * @email: 46914685@qq.com
 * @date: 2020/12/21 21:19
 */
@Controller
@RequestMapping("/month")
public class MonthLuckyController {

    @Autowired
    private IMonthLuckyService monthLuckyService;

    @GetMapping("/list")
    public String list(Model model) {
        PageHelper.startPage(2,3);
        System.out.println("list");

        MonthLucky monthLucky = new MonthLucky();
        List<MonthLucky> luckyList = monthLuckyService.selectMonthLuckyList(monthLucky);
        model.addAttribute("luckyList", luckyList);

        MonthLucky monthLucky1 = monthLuckyService.selectMonthLuckyById(2);

        model.addAttribute("lucky",monthLucky1);
        System.out.println(monthLucky1);
        ArrayList<String> names = new ArrayList<>();
        names.add("java");
        names.add("php");
        names.add("python");

        model.addAttribute("names",names);

        return "month/list";
    }
}

